using UnityEngine;
using System.Collections;

public class plr : MonoBehaviour {
	
	void Update () {
		
		if(Input.GetKey(KeyCode.Mouse0))
		{
			rigidbody.AddForce(transform.forward*10f);
		}
		
		Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		RaycastHit hit;

 
		if(Physics.Raycast(ray, out hit))
		{
			Vector3 targetDir = hit.point - transform.position;
			float step = 3f * Time.deltaTime;
			
	        Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0F);
	        Debug.DrawRay(transform.position, newDir, Color.red);
	        transform.rotation = Quaternion.LookRotation(newDir);
			
		}
	
	}
}
        
